package com.hjm.project.terminal.tailmoney.controller;

import java.util.List;

import com.hjm.project.terminal.tailmoney.domain.AgentPosTailmoney;
import com.hjm.project.terminal.tailmoney.service.IAgentPosTailmoneyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 服务商机具尾款信息Controller
 * 
 * @author LOVE
 * @date 2020-11-27
 */
@Controller
@RequestMapping("/terminal/tailmoney")
public class AgentPosTailmoneyController extends BaseController
{
    private String prefix = "terminal/tailmoney";

    @Autowired
    private IAgentPosTailmoneyService agentPosTailmoneyService;

    @RequiresPermissions("terminal:tailmoney:view")
    @GetMapping()
    public String tailmoney()
    {
        return prefix + "/tailmoney";
    }

    /**
     * 查询服务商机具尾款信息列表
     */
    @RequiresPermissions("terminal:tailmoney:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AgentPosTailmoney agentPosTailmoney)
    {
        startPage();
        List<AgentPosTailmoney> list = agentPosTailmoneyService.selectAgentPosTailmoneyList(agentPosTailmoney);
        return getDataTable(list);
    }

    /**
     * 导出服务商机具尾款信息列表
     */
    @RequiresPermissions("terminal:tailmoney:export")
    @Log(title = "服务商机具尾款信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgentPosTailmoney agentPosTailmoney)
    {
        List<AgentPosTailmoney> list = agentPosTailmoneyService.selectAgentPosTailmoneyList(agentPosTailmoney);
        ExcelUtil<AgentPosTailmoney> util = new ExcelUtil<AgentPosTailmoney>(AgentPosTailmoney.class);
        return util.exportExcel(list, "tailmoney");
    }

    /**
     * 新增服务商机具尾款信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存服务商机具尾款信息
     */
    @RequiresPermissions("terminal:tailmoney:add")
    @Log(title = "服务商机具尾款信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AgentPosTailmoney agentPosTailmoney)
    {
        return toAjax(agentPosTailmoneyService.insertAgentPosTailmoney(agentPosTailmoney));
    }

    /**
     * 修改服务商机具尾款信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AgentPosTailmoney agentPosTailmoney = agentPosTailmoneyService.selectAgentPosTailmoneyById(id);
        mmap.put("agentPosTailmoney", agentPosTailmoney);
        return prefix + "/edit";
    }

    /**
     * 修改保存服务商机具尾款信息
     */
    @RequiresPermissions("terminal:tailmoney:edit")
    @Log(title = "服务商机具尾款信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AgentPosTailmoney agentPosTailmoney)
    {
        return toAjax(agentPosTailmoneyService.updateAgentPosTailmoney(agentPosTailmoney));
    }

    /**
     * 删除服务商机具尾款信息
     */
    @RequiresPermissions("terminal:tailmoney:remove")
    @Log(title = "服务商机具尾款信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(agentPosTailmoneyService.deleteAgentPosTailmoneyByIds(ids));
    }
}
